/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Form;

/**
 *
 * @author Fave
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ProgressBar extends JWindow {

    int i =0;
    JLabel logo=new JLabel(new ImageIcon("src/image/banner1.jpg"));
    JProgressBar progress=new JProgressBar();
//    JLabel label = new JLabel("a"+i);

    int time;
    Timer timer; //* menggunakan Timer dari Java Swing
    Dimension dimensi=Toolkit.getDefaultToolkit().getScreenSize();

    public ProgressBar ()
    {
        Color warna=Color.WHITE;
        //* set warna background
        progress.setBackground(Color.black);
        progress.setForeground(Color.green);

        //* menempatkan gambar logo di bagian atas
        getContentPane().add(logo, BorderLayout.NORTH);
        //* menempatkan progress bar di bagian tengah
        getContentPane().add(progress, BorderLayout.CENTER);
//        getContentPane().add(label, BorderLayout.SOUTH);

        //* menempatkan lokasi progress bar
        setLocation(300,300);
        pack();
        show();

      
        timer=new Timer(20, new ActionListener() {

           public void actionPerformed(ActionEvent e)
           {
               //* waktu bertambah sampai presentase komplit
               time++;
//               i++;
//               label.setText("a"+i);
               progress.setValue(time);

               //* jika presentase komplit
               if(progress.getPercentComplete()==1)
               {
                   timer.stop(); //* therad timer dihentikan
                   setVisible(false);
                   //* membuka form Login
                   LoginForm l = new LoginForm();
                   l.setVisible(true);
//                   

               }
           }
        });

        //* memulai thread
          timer.start();
    }
    
    public static void main (String [] args) {
        ProgressBar p = new ProgressBar();
    }

}


